﻿using Commons.DomainBase;
using Kogel.Dapper.Extension.Attributes;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileService.Domain.Entities
{
    [Display(Rename = "time_tab")]
    public class TimeTab
    {

        [Identity]
        [Display(Rename = "id")]
        public long Id { get; set; }
        public string Name { set; get; }
        public DateTime Time { set; get; }

        public static TimeTab Create(string name)
        {
            string format = "yyyy年MM月dd日";
            DateTime dateTime = DateTime.ParseExact(name, format, CultureInfo.InvariantCulture);
            TimeTab item = new()
            {
                Name = name,
                Time = dateTime,
            };
            return item;
        }

        public TimeTab UpdataTime()
        {
            string format = "yyyy年MM月dd日";
            this.Time = DateTime.ParseExact(this.Name, format, CultureInfo.InvariantCulture);
            return this;
        }
    }
}
